<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <title>BMS</title>
    <script type="text/javascript" src="<s:url value="/js/jquery.validate.min.js"/>"></script>
    <script type="text/javascript" src="<s:url value="/js/directory/equipment.js"/>"></script>

</head>
<body>

<s:form id="formEdit" cssClass="tableEdit" enctype="multipart/form-data" cssStyle="margin: 10px 10% 0% 20%" >
    <tr>
        <th colspan="4" class="tableTitle">
            <h5>Equipment</h5>
        </th>
    </tr>
    <table id="table_contact" class="tableEditFixed" style="margin-left:0px">
        <col width="200px" />
        <col width="190px" />

        <s:select label="Site" id="siteCell%{#row.index + 1}"
                  headerKey="" headerValue="Choose a Site"
                  list="centroList"
                  listKey="id"
                  listValue="institucion"
                  name="centro.id"
                  value="%{equipmentcertification.centro.id}"
                >
        </s:select>
        <tr>
            <td><br/><br/></td>
        </tr>

           <s:hidden id="id" name="id" value="%{equipmentcertification.id}"  ></s:hidden>


                    <s:select label="Equipment Type"  id="typeCell%{#row.index}"
                              headerKey="" headerValue="Choose a Type"
                              list="equipmentTypes"
                              listKey="id"
                              listValue="description"
                              name="equipmentType.id"
                              value="%{equipmentcertification.equipmentType.id}"
                              cssClass="require type"
                            >
                    </s:select>

            <s:textfield label="Serial Number" id="serialNumberCell%{#row.index}" name="serialNumber" value="%{equipmentcertification.serialNumber}" cssClass="require serial"  />
            <s:textfield label="Location"  id="locationCell%{#row.index}" name="location" value="%{equipmentcertification.location}" cssClass="require location" />

            <s:select
                      id="calibrationCell%{#row.index}"
                      label="Calibration Frequncy"
                      name="calibrationFrequency"
                      list="#{'':'Choose a Calibration', '6':'6 months', '12':'1 year', '24':'2 year', '36':'3 year', '60':'5 year', '120':'10 year'}"
                      value="%{equipmentcertification.calibrationFrequency}"
                      cssClass="require calibration"
                      onchange="calcularfecha( $('#calibrationCell%{#row.index}').val(), $('#altlastcalibrationCell%{#row.index}').val(), '' );"
                    />



            <s:textfield label="Last calibration Date" id="lastcalibrationCell%{#row.index}"    cssClass="datepicker require" onchange="calcularfecha( $('#calibrationCell%{#row.index}').val(), $('#altlastcalibrationCell%{#row.index}').val(), '' );" />
            <tr>
                <td>
                    <s:hidden name="lastcalibrationCell" id="altlastcalibrationCell%{#row.index}" cssClass="last" value="%{equipmentcertification.lastcalibrationCell}" />
                </td>
            </tr>




            <s:textfield label="Expiration Date" id="expirationDateCell%{#row.index}"  cssClass="datepicker require"  />
            <tr>
                <td>
            <s:hidden name="expirationDate" id="altexpirationDateCell%{#row.index}" value="%{equipmentcertification.expirationDate}" cssClass="expiration"/>
                </td>
            </tr>

            <TR id="docAttachment1">
                <TD>
                    <label>Certification / Calibration:</label>
                </td>
                <td>
                    <s:file name="certificationFile" id="docAttachmentCell%{#row.index}" theme="simple"  cssClass="fileClass file data"  ></s:file>
                </TD>
                <td>
                    <label  style="color: red"></label>
                </td>
            </TR>
            <s:if test="%{equipmentcertification.filename != null}" >
                <tr>
                    <td style="font: 14px/14px 'Trebuchet ms','Trebuchet','Helvetica','Arial','sans-serif';">
                        <s:property value="%{equipmentcertification.filename}"  />
                    </td>
                    <td>
                        <s:url var="myurl" action="downloadFile" namespace="/" >
                            <s:param name="iddownload" value="%{equipmentcertification.id}" />
                        </s:url>
                        <s:a action="%{myurl}" > <img src="<s:url value="/images/b_download2.png"/>"style="width: 30px;height: 25px;" title="Download" alt="Download"> </s:a>

                    </td>
                </tr>
             </s:if>







    </table>

    <table class="tableEditFixed">
        <col width="125px" />
        <col width="155px" />
        <tr>
            <td colspan="2" class="centeredButtons">
                <s:submit value="Save" id="save" action="save" onclick="validate()"  theme="simple" />
            </td>
        </tr>
    </table>




</s:form>

<script type="text/javascript">
    hideField();
    $('#equipment').css({"color":"#EE5102","fontWeight":"bold"});
</script>

</body>
</html>
